package com.czd.support.service;

import com.czd.base.service.BaseService;
import com.czd.support.model.RoomProperty;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class RoomSettingService extends BaseService<RoomProperty>{

	public RoomProperty findOne(RoomProperty room){
		return this.selectOne(sqlId("findRoomSetting"), room);
	}
	
	public int insert(RoomProperty room){
		return this.insertAndReturnId(sqlId("insertRoomProperty"), room);
	}
	
	public boolean updateSert(RoomProperty room){
		if(room.getId() > 0){
			return this.update(sqlId("updateRoomProperty"), room);
		}else{
			return this.insert(sqlId("insertRoomProperty"), room);
		}
	}

	/**
	 * 检核推荐注册 的有效性
	 * @param rId 房间id
	 * @param recommendUserId 推荐客服id
	 * @return
	 */
	public boolean checkRecommend(int rId, int recommendUserId) {
		Map<String ,Object> m = new HashMap<>();
		m.put("roomId",rId);
		m.put("recommendUserId",recommendUserId);
		return this.count(sqlId("checkRecommend"),m) > 0;
	}
}
